package com.tcxhb.job.admin.demo.job;

import com.alibaba.fastjson.JSONObject;
import com.tcxhb.job.agent.processor.JobProcessor;
import com.tcxhb.job.common.model.MiscResult;
import com.tcxhb.job.common.model.job.JobContext;
import com.tcxhb.job.common.utils.JsonUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @Description:
 * @Auther: tcxhb
 * @Date: 2023/11/5
 */
@Component
@Slf4j
public class LongTimeJobDemo implements JobProcessor {

    @Override
    public MiscResult process(JobContext context) {
        try {
            JSONObject params = JsonUtils.toJson(context.getParams());
            Integer sleep = 3;
            if (params != null) {
                sleep = params.getInteger("sleep");
            }
            log.info("LongTimeJobDemo");
            Thread.sleep(1000 * 60 * sleep);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return MiscResult.suc();
    }
}
